Skip to content

clipboard support: code-server --stdin-to-clipboard #6807

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 21, 2024

Conversation

smerschjohann
Copy link
Contributor

This PR adds support for pasting to clipboard from STDIN. This is especially useful from the integrated terminal.

Use like this:

# directly from the integrated terminal
echo -n "HELLO CODE-SERVER!" | code-server --stdin-to-clipboard

# as an alias
alias xclip="code-server --stdin-to-clipboard"
echo -n "HELLO FROM ALIAS!" | xclip

# or from an executable
sudo tee /usr/local/bin/xclip << EOF
#!/bin/sh
code-server --stdin-to-clipboard
EOF
sudo chmod +x /usr/local/bin/xclip
echo -n "HELLO FROM executable!" | xclip

Fixes #6175

@smerschjohann smerschjohann requested a review from a team as a code owner May 21, 2024 17:33
Copy link
Member

@code-asher code-asher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very cool. One of those features that feels kinda like magic. 🪄

@code-asher code-asher merged commit efc6edf into coder:main May 21, 2024
9 checks passed
@smerschjohann
Copy link
Contributor Author

Yeah, it kind of is ;)

From terminal to "remote cli", from there via a Unix socket to code-server. Then it uses the general clipboard service which passes it to the Browser clipboard API. This approves the request because the browser window is in focus. Finally, the data is sent to the local clipboard.

A lot of steps but works nicely. 👍

@smerschjohann smerschjohann deleted the clipboard-support branch May 21, 2024 19:11
yiliang114 pushed a commit to yiliang114/code-server that referenced this pull request Jan 23, 2025
Use --stdin-to-clipboard or -c to pass stdin to clipboard
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feat]: clipboard support
2 participants